//
//  CProcessFunctions.h
//  FlashAnimation
//
//  Created by bk on 13/1/1.
//  Copyright (c) 2013年 __MyCompanyName__. All rights reserved.
//

#ifndef CProcessFunctions_H
#define CProcessFunctions_H

#include <stddef.h>
#include <map>

using namespace std;

template <typename T>
class CProcessFunctions
{
public:
    
    typedef void (T::*onProcessFunPtr)();
    
    CProcessFunctions()
    {
        m_classPtr = NULL;
    }
    
    CProcessFunctions(T* classPtr)
    {
        m_classPtr = classPtr;
    }
    
    void Register(int nKey,onProcessFunPtr pFunPtr)
    {
        m_mapPrceFunPtr[nKey]=pFunPtr;
    }
    
    void processFun(int nProcKey)
    {
        if(m_classPtr != NULL && m_mapPrceFunPtr.count(nProcKey))
        {
            if(m_mapPrceFunPtr[nProcKey] != NULL)
                (m_classPtr->*m_mapPrceFunPtr[nProcKey])();
        }
    }
    
protected:
    
    int                      m_nCurrProcess;
    
    //int                      m_nNextProcess;
    
private:
    
    T*                       m_classPtr;
    
    map<int,onProcessFunPtr> m_mapPrceFunPtr;
    
};


#endif
